package com.service.report;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

import com.bpms.atmp.client.common.GVO;
import com.bpms.common.CommonUtil;
import com.bpms.common.Param;
import com.bpms.common.Tools;
import com.bpms.common.VO;
import com.bpms.common.VOList;
import com.bpms.esb.IService;
/**
 * 实现对流水账单数据整合
 * @author 
 *
 */
public class Lsprintreport implements IService {

	public VO exec(VO arg0) {
		VO result = new VO();
		VOList relist = new VOList();
		try{
			VOList list = (VOList) arg0.getObj("volist");
			Vector v = list.listData;
			Iterator it = v.iterator();
			
			while(it.hasNext()){
				VO vo = (VO)it.next();//循环读取
				VO temp = new VO();//临时数据
//				String trantype = vo.getAttr("trantype");
//				String count = vo.getAttr("count");
//				vo.setAttr("count" + trantype,count);
				
//				temp.setAttr("TOTAL", vo.getAttr("count01"));
//				temp.setAttr("ZP", vo.getAttr("count02"));
//				temp.setAttr("", vo.getAttr("count03"));
				
				temp.setAttr("JYSJ", vo.getAttr("CREATDATE"));//交易时间
				temp.setAttr("JYZH", vo.getAttr("PAYEEACCNO"));  //交易账号
				temp.setAttr("JYHM", vo.getAttr("NAME"));  //交易户名
				temp.setAttr("JYLX", vo.getAttr("TRANTYPE")); 	   //交易类型
				temp.setAttr("JYLSH", vo.getAttr("BIZID"));   //交易流水号
						
				CommonUtil.debug("get trantype from param ATM.TRANTYPE" + vo.getAttr("TRANTYPE"));//debug

				relist.listData.add(temp);
			}
			result.setObj("list", relist);
			Map<String,String> summary = new HashMap<String,String>();

			summary.put("TOTAL", arg0.getAttr("total"));
			summary.put("CC", arg0.getAttr("cc"));
			summary.put("ZP",  arg0.getAttr("zp"));
			summary.put("DJPZ", arg0.getAttr("djpz"));
			
			result.setObj("summary", summary);
			
		}catch(Exception e){
			CommonUtil.debug("HdPrintReport exception");
		}
		return result;
	}

//	String[] toNum(String str){
//		String s = "";
//		String[] attr = new String[]{};
//		for(int i = str.length(); i>=0 ;i--){
//			if(i+1>str.length()){
//				s = str.substring(i);
//			}else{
//				s = str.substring(i, i+1);
//			}
//			attr = Arrays.copyOf(attr, attr.length + 1);
//			attr[attr.length-1] = s;
//		}
//		attr = Arrays.copyOf(attr, attr.length + 1);
//		attr[attr.length-1] = "￥";
//		int len = attr.length;
//		if(len<15){
//			for(int j = len;j<=15;j++){
//				attr = Arrays.copyOf(attr, attr.length + 1);
//				attr[j] = " ";
//			}
//		}
//		return attr;
//	}

}
